//
//  JFLapolicyHelper.h
//  JFBase
//
//  Created by Alan Wang on 2019/7/26.
//  Copyright © 2019 Alan Wang. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <LocalAuthentication/LocalAuthentication.h>

NS_ASSUME_NONNULL_BEGIN
typedef NS_ENUM(NSUInteger, JFLapolicyType){
    JFLapolicyType_None=0,
    JFLapolicyType_TouchId=1,
    JFLapolicyType_FaceId=2
    
};
/**
 *  TouchID/FaceID 状态
 */
typedef NS_ENUM(NSUInteger, JFLapolicyState){
    
    /**
     *  当前设备不支持TouchID/FaceID
     */
    JFLapolicyState_NotSupport = 0,
    /**
     *  TouchID/FaceID 验证成功
     */
    JFLapolicyState_Success = 1,
    
    /**
     *  TouchID/FaceID 验证失败
     */
    JFLapolicyState_Failed = 2,
    /**
     *  TouchID/FaceID 被用户手动取消
     */
    JFLapolicyState_UserCancel = 3,
    /**
     *  用户不使用TouchID/FaceID,选择手动输入密码
     */
    JFLapolicyState_InputPassword = 4,
    /**
     *  TouchID/FaceID 被系统取消 (如遇到来电,锁屏,按了Home键等)
     */
    JFLapolicyState_SystemCancel = 5,
    /**
     *  TouchID/FaceID 无法启动,因为用户没有设置密码
     */
    JFLapolicyState_PasswordNotSet = 6,
    /**
     *  TouchID/FaceID 无法启动,因为用户没有设置TouchID/FaceID
     */
    JFLapolicyState_NotSet = 7,
    /**
     *  TouchID/FaceID 无效
     */
    JFLapolicyState_NotAvailable = 8,
    /**
     *  TouchID/FaceID 被锁定(连续多次验证TouchID/FaceID失败,系统需要用户手动输入密码)
     */
    JFLapolicyState_Lockout = 9,
    /**
     *  当前软件被挂起并取消了授权 (如App进入了后台等)
     */
    JFLapolicyState_AppCancel = 10,
    /**
     *  当前软件被挂起并取消了授权 (LAContext对象无效)
     */
    JFLapolicyState_InvalidContext = 11,
    /**
     *  系统版本不支持TouchID/FaceID (必须高于iOS 8.0才能使用)
     */
    JFLapolicyState_VersionNotSupport = 12,
    /**
     *  TouchID/FaceID 无法启动,因为用户没有设置TouchID/FaceID
     */
    JFLapolicyState_NotEnrolled = 13
};
typedef void (^JFLapolicyHelperStateBlock)(JFLapolicyState state, NSError *error,NSString * msg);
@interface JFLapolicyHelper : NSObject
+(JFLapolicyType)supportLapolicyType;
+(void)checkLaPolicyState:(NSString*)localizedReason fallbackTitle:(NSString*)fallbackTitle stateBlock:(JFLapolicyHelperStateBlock)block;
@end

NS_ASSUME_NONNULL_END
